package com.ebupt.migu.music.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 基础校验
 *
 * @author liuyangyang@cd.ebupt.com
 */
public class PatternVer {

    /**
     * 手机号码校验
     */
    //原先正则规则：  ^(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$
    //2022年最新正则：^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$
//     private static final Pattern pattern = Pattern.compile("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
     private static final Pattern pattern = Pattern.compile("^1\\d{10}$");
//    private static final Pattern pattern = Pattern.compile("^1[0-9]{10}$");


    /**
     * 对手机号码进行格式校验
     *
     * @param msisdn
     * @return
     */
    public static boolean isMsisdn(String msisdn) {
        Matcher matcher = pattern.matcher(msisdn);
        return matcher.matches();
    }

    public static void main(String[] args) {
        String msisdn = "19720609496";
        Pattern pattern = Pattern.compile("^1[0-9]{10}$");
        Matcher matcher = pattern.matcher(msisdn);
        System.out.println(msisdn);
        System.out.println(matcher.matches());
    }
}
